﻿using System;

public class Person : IPropertyChangeNotification
{
    private DateTime birthDate;
    private string firstName;
    private string gender;
    private string lastName;
    private PropertyChangedEventHandler propertyChanged;

    public event PropertyChangedEventHandler PropertyChanged 
    {
        add
        {
            propertyChanged += value;
        }
        remove
        {
            propertyChanged -= value;
        }
    }

    public DateTime BirthDate
    {
        get
        {
            return birthDate;
        }
        set
        {
            if (value != birthDate)
            {
                OnPropertyChange("Birthdate", birthDate, value);
            }
            birthDate = value;
            
        }
    }
    public string FirstName
    {
        get
        {
            return firstName;
        }
        set
        {
            if (value != firstName)
            {
                OnPropertyChange("FirstName", firstName, value);
            }
            firstName = value;
        }
    }
    public string Gender
    {
        get
        {
            return gender;
        }
        set
        {
            if (value != gender)
            {
                OnPropertyChange("Gender", gender, value);
            }
            gender = value;
        }
    }
    public string LastName
    {
        get
        {
            return lastName;
        }
        set
        {
            if (value != lastName)
            {
                OnPropertyChange("Gender", gender, value);
            }
            lastName = value;
        }
    }

    private void OnPropertyChange(string property, object oldValue, object newValue)
    {
        if (propertyChanged != null)
        {
            propertyChanged(this, new PropertyChangedEventArgs(property, oldValue, newValue));
        }
    }
}